package cate.game.play.skill.effect;


import cate.common.table.d.GDSkill;
import cate.common.util.XT;
import cate.game.play.config.skill.SkillCfg;
import cate.game.play.skill.effect.base.SE;
import org.apache.commons.lang3.StringUtils;

public class SEFactory {


    public static SE build(String effectType, SkillCfg cfg) {
        SE se = createByType(effectType);
        if (StringUtils.isNotBlank(cfg.row.effectCfgCode)) {
            se.parse(cfg.row.effectCfgCode);
        }
        if (XT.isNotBlank(cfg.enhance.exEffects)) {
            for (String exCode : cfg.enhance.exEffects) {
                se.parseExt(exCode);
            }
        }
        return se;
    }

    private static SE createByType(String effectType) {
        switch (effectType) {
            case GDSkill.EffectType.伤害:
                return new 伤害SE();
            case GDSkill.EffectType.治疗:
                return new 治疗SE();
            case GDSkill.EffectType.复活:
                return new 复活SE();
            case GDSkill.EffectType.驱散:
                return new 驱散SE();
            default:
                return new 空SE();
        }
    }


}
